home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / otohime / src / lib / smix.asm < prev    next >
Assembly Source File  |  1994-06-01  |  2KB  |  139 lines

  1. ;        SOUND DATA OVERLAP TRANS
  2. ;
  3. ;        call from F-BASIC386 or High C
  4. ;    callm address,varptr(source),varptr(new)
  5. ;
  6. ;
  7. ;        1990 3  Hiroshi TODA
  8. ;
  9. ;        1993 12 Hicg C用に改造
  10. ;
  11. ;
  12.  
  13.     .386p
  14.  
  15. param    struc
  16.  
  17.     dd    ?
  18.     dd    ?
  19. source    dd    ?        ; source snd.data address
  20. new    dd    ?        ; new snd.data address
  21. paradd    dd    ?        ; param. address
  22. wadd    dd    ?         ; work address
  23.  
  24. param   ends
  25.  
  26. work    struc
  27.  
  28. ;data area
  29.  
  30. rate1    dd    ?        ; main rate
  31. rate2    dd    ?        ; trans source rate
  32. max    dd    ?        ; max data length
  33.  
  34. ;work area
  35.  
  36. buf    dd    ?
  37.  
  38. work    ends
  39.  
  40.  
  41. cseg    segment    dword public use32 'CODE'
  42.     assume    cs:cseg,ds:cseg
  43.  
  44.     public    sndMixTrans
  45.     db    'sndMixTrans',11
  46. sndMixTrans    proc    near
  47.     push    ebp
  48.     mov    ebp,esp
  49.     push    esi
  50.     push    edi
  51.     push    ebx
  52.     mov    esi,[ebp].wadd        ; esi <-- work area top add
  53.     mov    ecx,[ebp].paradd    ; ecx <-- para. add.
  54.     xor    edx,edx            ; edx=count
  55. main01:    mov    eax,[ecx][edx*4]    ; para. --> work area
  56.     mov    [esi][edx*4],eax
  57.     inc    edx
  58.     cmp    edx,3
  59.     jb    main01
  60.  
  61.     mov    ebx,[ebp].source    ; ebx <-- source snd. add.
  62.     mov    edi,[ebp].new        ; edi <-- new snd. add.
  63.  
  64.  
  65. ; この部分の追加 1993 12
  66.     mov    eax,[edi+12]        ; max check ( new snd length )
  67.     cmp    eax,[esi].max
  68.     jbe main0A0
  69.     mov    eax,[esi].max
  70.     mov    [edi+12],eax
  71. main0A0:
  72.     mov    ecx,[ebx+12]        ; ecx <-- source data length
  73.     cmp    ecx,[edi+12]        ; new sndのlengthと比較
  74.     jae main0A5
  75. main0A1:
  76.     mov    byte ptr [ebx+32][ecx],128    ; はみ出た部分に0信号を置く
  77.     inc ecx
  78.     cmp ecx,[edi+12]
  79.     jb main0A1
  80. main0A5:
  81.     mov ecx,[edi+12]
  82.  
  83.  
  84.     cmp    ecx,0
  85.     je    mainE
  86.     cmp    ecx,[esi].max
  87.     jbe    main0A
  88.     mov    ecx,[esi].max
  89. main0A:    add    ebx,32            ; add head(32Byte)
  90.     add    edi,32
  91. main02:    mov    al,[ebx]        ; read source
  92.     and    eax,0ffH
  93.     cmp    eax,128
  94.     jb    main03
  95.     mov    edx,eax
  96.     mov    eax,128
  97.     sub    eax,edx
  98. main03:    imul    eax,[esi].rate1
  99.     mov    [esi].buf,eax
  100. main04:    mov    al,[edi]        ; read new
  101.     and    eax,0ffH
  102.     cmp    eax,128
  103.     jb    main05
  104.     mov    edx,eax
  105.     mov    eax,128
  106.     sub    eax,edx
  107. main05:    imul    eax,[esi].rate2
  108.     add    eax,[esi].buf
  109.     sar    eax,8
  110.     cmp    eax,0            ; write
  111.     js    wr01
  112.     je    wr01
  113.     cmp    eax,128            ; +
  114.     jb    wr02
  115.     mov    eax,127
  116.     jmp    wr02
  117. wr01:    mov    edx,eax            ; -
  118.     mov    eax,128
  119.     sub    eax,edx
  120.     cmp    eax,256-1    ; data255はloopStopの意味があるから除外 1993 12
  121.     jb    wr02
  122.     mov    eax,255-1    ; data255はloopStopの意味があるから除外 1993 12
  123. wr02:    mov    [edi],al
  124.     inc    ebx
  125.     inc    edi
  126.     dec    ecx
  127.     jne    main02
  128. mainE:
  129.     pop    ebx
  130.     pop    edi
  131.     pop    esi
  132.     mov    esp,ebp
  133.     pop    ebp
  134.     ret
  135. sndMixTrans    endp
  136.  
  137. cseg    ends
  138.     end
  139.